
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/testing/runtests.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:10 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Run Tests &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="runtests.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Utilities" href="../utilities/index.html" />
    <link rel="prev" title="Randomised Testing" href="randtest.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../utilities/index.html" title="Utilities"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="randtest.html" title="Randomised Testing"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Testing</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Run Tests</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.testing.runtests">
<span id="run-tests"></span><h1>Run Tests<a class="headerlink" href="#module-sympy.testing.runtests" title="Permalink to this headline">¶</a></h1>
<p>This is our testing framework.</p>
<p>Goals:</p>
<ul class="simple">
<li><p>it should be compatible with py.test and operate very similarly
(or identically)</p></li>
<li><p>doesn’t require any external dependencies</p></li>
<li><p>preferably all the functionality should be in this file only</p></li>
<li><p>no magic, just import the test file and execute the test functions, that’s it</p></li>
<li><p>portable</p></li>
</ul>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.testing.runtests.PyTestReporter">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">PyTestReporter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">verbose</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tb</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'short'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">colors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">force_colors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">split</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L1965-L2380"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.PyTestReporter" title="Permalink to this definition">¶</a></dt>
<dd><p>Py.test like reporter. Should produce output identical to py.test.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.testing.runtests.PyTestReporter.write">
<span class="sig-name descname"><span class="pre">write</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">color</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">align</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'left'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">force_colors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L2070-L2158"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.PyTestReporter.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Prints a text on the screen.</p>
<p>It uses sys.stdout.write(), so no readline library is necessary.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>color</strong> : choose from the colors below, “” means default color</p>
<p><strong>align</strong> : “left”/”right”, “left” is a normal print, “right” is aligned on</p>
<blockquote>
<div><p>the right-hand side of the screen, filled with spaces if
necessary</p>
</div></blockquote>
<p><strong>width</strong> : the screen width</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.testing.runtests.Reporter">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">Reporter</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L1958-L1962"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.Reporter" title="Permalink to this definition">¶</a></dt>
<dd><p>Parent class for all reporters.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.testing.runtests.SymPyDocTestFinder">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">SymPyDocTestFinder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="pre">verbose=False</span></em>, <em class="sig-param"><span class="pre">parser=&lt;doctest.DocTestParser</span> <span class="pre">object&gt;</span></em>, <em class="sig-param"><span class="pre">recurse=True</span></em>, <em class="sig-param"><span class="pre">exclude_empty=True</span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L1588-L1774"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.SymPyDocTestFinder" title="Permalink to this definition">¶</a></dt>
<dd><p>A class used to extract the DocTests that are relevant to a given
object, from its docstring and the docstrings of its contained
objects.  Doctests can currently be extracted from the following
object types: modules, functions, classes, methods, staticmethods,
classmethods, and properties.</p>
<p>Modified from doctest’s version to look harder for code that
appears comes from a different module. For example, the &#64;vectorize
decorator makes it look like functions come from multidimensional.py
even though their code exists elsewhere.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.testing.runtests.SymPyDocTestRunner">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">SymPyDocTestRunner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">checker</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbose</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optionflags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L1777-L1845"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.SymPyDocTestRunner" title="Permalink to this definition">¶</a></dt>
<dd><p>A class used to run DocTest test cases, and accumulate statistics.
The <code class="docutils literal notranslate"><span class="pre">run</span></code> method is used to process a single DocTest case.  It
returns a tuple <code class="docutils literal notranslate"><span class="pre">(f,</span> <span class="pre">t)</span></code>, where <code class="docutils literal notranslate"><span class="pre">t</span></code> is the number of test cases
tried, and <code class="docutils literal notranslate"><span class="pre">f</span></code> is the number of test cases that failed.</p>
<p>Modified from the doctest version to not reset the sys.displayhook (see
issue 5140).</p>
<p>See the docstring of the original DocTestRunner for more information.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.testing.runtests.SymPyDocTestRunner.run">
<span class="sig-name descname"><span class="pre">run</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">test</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compileflags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clear_globs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L1790-L1845"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.SymPyDocTestRunner.run" title="Permalink to this definition">¶</a></dt>
<dd><p>Run the examples in <code class="docutils literal notranslate"><span class="pre">test</span></code>, and display the results using the
writer function <code class="docutils literal notranslate"><span class="pre">out</span></code>.</p>
<p>The examples are run in the namespace <code class="docutils literal notranslate"><span class="pre">test.globs</span></code>.  If
<code class="docutils literal notranslate"><span class="pre">clear_globs</span></code> is true (the default), then this namespace will
be cleared after the test runs, to help with garbage
collection.  If you would like to examine the namespace after
the test completes, then use <code class="docutils literal notranslate"><span class="pre">clear_globs=False</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">compileflags</span></code> gives the set of flags that should be used by
the Python compiler when running the examples.  If not
specified, then it will default to the set of future-import
flags that apply to <code class="docutils literal notranslate"><span class="pre">globs</span></code>.</p>
<p>The output of each example is checked using
<code class="docutils literal notranslate"><span class="pre">SymPyDocTestRunner.check_output</span></code>, and the results are
formatted by the <code class="docutils literal notranslate"><span class="pre">SymPyDocTestRunner.report_*</span></code> methods.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.testing.runtests.SymPyOutputChecker">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">SymPyOutputChecker</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L1860-L1955"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.SymPyOutputChecker" title="Permalink to this definition">¶</a></dt>
<dd><p>Compared to the OutputChecker from the stdlib our OutputChecker class
supports numerical comparison of floats occurring in the output of the
doctest examples</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.testing.runtests.SymPyOutputChecker.check_output">
<span class="sig-name descname"><span class="pre">check_output</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">want</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">got</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optionflags</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L1887-L1955"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.SymPyOutputChecker.check_output" title="Permalink to this definition">¶</a></dt>
<dd><p>Return True iff the actual output from an example (<span class="math notranslate nohighlight">\(got\)</span>)
matches the expected output (<span class="math notranslate nohighlight">\(want\)</span>).  These strings are
always considered to match if they are identical; but
depending on what option flags the test runner is using,
several non-exact match types are also possible.  See the
documentation for <span class="math notranslate nohighlight">\(TestRunner\)</span> for more information about
option flags.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.testing.runtests.SymPyTestResults">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">SymPyTestResults</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">failed</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attempted</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.SymPyTestResults" title="Permalink to this definition">¶</a></dt>
<dd><dl class="py attribute">
<dt class="sig sig-object py" id="sympy.testing.runtests.SymPyTestResults.attempted">
<span class="sig-name descname"><span class="pre">attempted</span></span><a class="headerlink" href="#sympy.testing.runtests.SymPyTestResults.attempted" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for field number 1</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="sympy.testing.runtests.SymPyTestResults.failed">
<span class="sig-name descname"><span class="pre">failed</span></span><a class="headerlink" href="#sympy.testing.runtests.SymPyTestResults.failed" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for field number 0</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.convert_to_native_paths">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">convert_to_native_paths</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lst</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L131-L147"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.convert_to_native_paths" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts a list of ‘/’ separated paths into a list of
native (os.sep separated) paths and converts to lowercase
if the system is case insensitive.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.doctest">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">doctest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">paths</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subprocess</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rerun</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L576-L646"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.doctest" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs doctests in all *.py files in the sympy directory which match
any of the given strings in <code class="docutils literal notranslate"><span class="pre">paths</span></code> or all tests if paths=[].</p>
<p>Notes:</p>
<ul class="simple">
<li><p>Paths can be entered in native system format or in unix,
forward-slash format.</p></li>
<li><p>Files that are on the blacklist can be tested by providing
their path; they are only excluded if no paths are given.</p></li>
</ul>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">sympy</span>
</pre></div>
</div>
<p>Run all tests:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">doctest</span><span class="p">()</span> 
</pre></div>
</div>
<p>Run one file:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">doctest</span><span class="p">(</span><span class="s2">&quot;sympy/core/basic.py&quot;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">doctest</span><span class="p">(</span><span class="s2">&quot;polynomial.rst&quot;</span><span class="p">)</span> 
</pre></div>
</div>
<p>Run all tests in sympy/functions/ and some particular file:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">doctest</span><span class="p">(</span><span class="s2">&quot;/functions&quot;</span><span class="p">,</span> <span class="s2">&quot;basic.py&quot;</span><span class="p">)</span> 
</pre></div>
</div>
<p>Run any file having polynomial in its name, doc/src/modules/polynomial.rst,
sympy/functions/special/polynomials.py, and sympy/polys/polynomial.py:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">doctest</span><span class="p">(</span><span class="s2">&quot;polynomial&quot;</span><span class="p">)</span> 
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">split</span></code> option can be passed to split the test run into parts. The
split currently only splits the test files, though this may change in the
future. <code class="docutils literal notranslate"><span class="pre">split</span></code> should be a string of the form ‘a/b’, which will run
part <code class="docutils literal notranslate"><span class="pre">a</span></code> of <code class="docutils literal notranslate"><span class="pre">b</span></code>. Note that the regular doctests and the Sphinx
doctests are split independently. For instance, to run the first half of
the test suite:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">doctest</span><span class="p">(</span><span class="n">split</span><span class="o">=</span><span class="s1">&#39;1/2&#39;</span><span class="p">)</span>  
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">subprocess</span></code> and <code class="docutils literal notranslate"><span class="pre">verbose</span></code> options are the same as with the function
<code class="docutils literal notranslate"><span class="pre">test()</span></code>.  See the docstring of that function for more information.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.get_sympy_dir">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">get_sympy_dir</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L150-L158"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.get_sympy_dir" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the root sympy directory and set the global value
indicating whether the system is case sensitive or not.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.raise_on_deprecated">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">raise_on_deprecated</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L176-L187"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.raise_on_deprecated" title="Permalink to this definition">¶</a></dt>
<dd><p>Context manager to make DeprecationWarning raise an error</p>
<p>This is to catch SymPyDeprecationWarning from library code while running
tests and doctests. It is important to use this context manager around
each individual test/doctest in case some tests modify the warning
filters.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.run_all_tests">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">run_all_tests</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">test_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">test_kwargs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">doctest_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">doctest_kwargs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">examples_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">examples_kwargs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L282-L337"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.run_all_tests" title="Permalink to this definition">¶</a></dt>
<dd><p>Run all tests.</p>
<p>Right now, this runs the regular tests (bin/test), the doctests
(bin/doctest), and the examples (examples/all.py).</p>
<p>This is what <code class="docutils literal notranslate"><span class="pre">setup.py</span> <span class="pre">test</span></code> uses.</p>
<p>You can pass arguments and keyword arguments to the test functions that
support them (for now, test,  doctest, and the examples). See the
docstrings of those functions for a description of the available options.</p>
<p>For example, to run the solvers tests with colors turned off:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.testing.runtests</span> <span class="kn">import</span> <span class="n">run_all_tests</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">run_all_tests</span><span class="p">(</span><span class="n">test_args</span><span class="o">=</span><span class="p">(</span><span class="s2">&quot;solvers&quot;</span><span class="p">,),</span>
<span class="gp">... </span><span class="n">test_kwargs</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;colors:False&quot;</span><span class="p">})</span> 
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.run_in_subprocess_with_hash_randomization">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">run_in_subprocess_with_hash_randomization</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function_kwargs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">command</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'/home/runner/work/sympy/sympy/release/venv_main/bin/python3'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">module</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'sympy.testing.runtests'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L190-L279"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.run_in_subprocess_with_hash_randomization" title="Permalink to this definition">¶</a></dt>
<dd><p>Run a function in a Python subprocess with hash randomization enabled.</p>
<p>If hash randomization is not supported by the version of Python given, it
returns False.  Otherwise, it returns the exit value of the command.  The
function is passed to sys.exit(), so the return value of the function will
be the return value.</p>
<p>The environment variable PYTHONHASHSEED is used to seed Python’s hash
randomization.  If it is set, this function will return False, because
starting a new subprocess is unnecessary in that case.  If it is not set,
one is set at random, and the tests are run.  Note that if this
environment variable is set when Python starts, hash randomization is
automatically enabled.  To force a subprocess to be created even if
PYTHONHASHSEED is set, pass <code class="docutils literal notranslate"><span class="pre">force=True</span></code>.  This flag will not force a
subprocess in Python versions that do not support hash randomization (see
below), because those versions of Python do not support the <code class="docutils literal notranslate"><span class="pre">-R</span></code> flag.</p>
<p><code class="docutils literal notranslate"><span class="pre">function</span></code> should be a string name of a function that is importable from
the module <code class="docutils literal notranslate"><span class="pre">module</span></code>, like “_test”.  The default for <code class="docutils literal notranslate"><span class="pre">module</span></code> is
“sympy.testing.runtests”.  <code class="docutils literal notranslate"><span class="pre">function_args</span></code> and <code class="docutils literal notranslate"><span class="pre">function_kwargs</span></code>
should be a repr-able tuple and dict, respectively.  The default Python
command is sys.executable, which is the currently running Python command.</p>
<p>This function is necessary because the seed for hash randomization must be
set by the environment variable before Python starts.  Hence, in order to
use a predetermined seed for tests, we must start Python in a separate
subprocess.</p>
<p>Hash randomization was added in the minor Python versions 2.6.8, 2.7.3,
3.1.5, and 3.2.3, and is enabled by default in all Python versions after
and including 3.3.0.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.testing.runtests</span> <span class="kn">import</span> <span class="p">(</span>
<span class="gp">... </span><span class="n">run_in_subprocess_with_hash_randomization</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># run the core tests in verbose mode</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">run_in_subprocess_with_hash_randomization</span><span class="p">(</span><span class="s2">&quot;_test&quot;</span><span class="p">,</span>
<span class="gp">... </span><span class="n">function_args</span><span class="o">=</span><span class="p">(</span><span class="s2">&quot;core&quot;</span><span class="p">,),</span>
<span class="gp">... </span><span class="n">function_kwargs</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;verbose&#39;</span><span class="p">:</span> <span class="kc">True</span><span class="p">})</span> 
<span class="go"># Will return 0 if sys.executable supports hash randomization and tests</span>
<span class="go"># pass, 1 if they fail, and False if it does not support hash</span>
<span class="go"># randomization.</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.split_list">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">split_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">l</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">split</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">density</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L913-L968"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.split_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Splits a list into part a of b</p>
<p>split should be a string of the form ‘a/b’. For instance, ‘1/3’ would give
the split one of three.</p>
<p>If the length of the list is not divisible by the number of splits, the
last split will have more items.</p>
<p><span class="math notranslate nohighlight">\(density\)</span> may be specified as a list.  If specified,
tests will be balanced so that each split has as equal-as-possible
amount of mass according to <span class="math notranslate nohighlight">\(density\)</span>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.testing.runtests</span> <span class="kn">import</span> <span class="n">split_list</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">split_list</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="s1">&#39;1/3&#39;</span><span class="p">)</span>
<span class="go">[0, 1, 2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">split_list</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="s1">&#39;2/3&#39;</span><span class="p">)</span>
<span class="go">[3, 4, 5]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">split_list</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="s1">&#39;3/3&#39;</span><span class="p">)</span>
<span class="go">[6, 7, 8, 9]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.sympytestfile">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">sympytestfile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="pre">filename</span></em>, <em class="sig-param"><span class="pre">module_relative=True</span></em>, <em class="sig-param"><span class="pre">name=None</span></em>, <em class="sig-param"><span class="pre">package=None</span></em>, <em class="sig-param"><span class="pre">globs=None</span></em>, <em class="sig-param"><span class="pre">verbose=None</span></em>, <em class="sig-param"><span class="pre">report=True</span></em>, <em class="sig-param"><span class="pre">optionflags=0</span></em>, <em class="sig-param"><span class="pre">extraglobs=None</span></em>, <em class="sig-param"><span class="pre">raise_on_error=False</span></em>, <em class="sig-param"><span class="pre">parser=&lt;doctest.DocTestParser</span> <span class="pre">object&gt;</span></em>, <em class="sig-param"><span class="pre">encoding=None</span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L973-L1100"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.sympytestfile" title="Permalink to this definition">¶</a></dt>
<dd><p>Test examples in the given file.  Return (#failures, #tests).</p>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">module_relative</span></code> specifies how filenames
should be interpreted:</p>
<ul class="simple">
<li><p>If <code class="docutils literal notranslate"><span class="pre">module_relative</span></code> is True (the default), then <code class="docutils literal notranslate"><span class="pre">filename</span></code>
specifies a module-relative path.  By default, this path is
relative to the calling module’s directory; but if the
<code class="docutils literal notranslate"><span class="pre">package</span></code> argument is specified, then it is relative to that
package.  To ensure os-independence, <code class="docutils literal notranslate"><span class="pre">filename</span></code> should use
“/” characters to separate path segments, and should not
be an absolute path (i.e., it may not begin with “/”).</p></li>
<li><p>If <code class="docutils literal notranslate"><span class="pre">module_relative</span></code> is False, then <code class="docutils literal notranslate"><span class="pre">filename</span></code> specifies an
os-specific path.  The path may be absolute or relative (to
the current working directory).</p></li>
</ul>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">name</span></code> gives the name of the test; by default
use the file’s basename.</p>
<p>Optional keyword argument <code class="docutils literal notranslate"><span class="pre">package</span></code> is a Python package or the
name of a Python package whose directory should be used as the
base directory for a module relative filename.  If no package is
specified, then the calling module’s directory is used as the base
directory for module relative filenames.  It is an error to
specify <code class="docutils literal notranslate"><span class="pre">package</span></code> if <code class="docutils literal notranslate"><span class="pre">module_relative</span></code> is False.</p>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">globs</span></code> gives a dict to be used as the globals
when executing examples; by default, use {}.  A copy of this dict
is actually used for each docstring, so that each docstring’s
examples start with a clean slate.</p>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">extraglobs</span></code> gives a dictionary that should be
merged into the globals that are used to execute examples.  By
default, no extra globals are used.</p>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">verbose</span></code> prints lots of stuff if true, prints
only failures if false; by default, it’s true iff “-v” is in sys.argv.</p>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">report</span></code> prints a summary at the end when true,
else prints nothing at the end.  In verbose mode, the summary is
detailed, else very brief (in fact, empty if all tests passed).</p>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">optionflags</span></code> or’s together module constants,
and defaults to 0.  Possible values (see the docs for details):</p>
<ul class="simple">
<li><p>DONT_ACCEPT_TRUE_FOR_1</p></li>
<li><p>DONT_ACCEPT_BLANKLINE</p></li>
<li><p>NORMALIZE_WHITESPACE</p></li>
<li><p>ELLIPSIS</p></li>
<li><p>SKIP</p></li>
<li><p>IGNORE_EXCEPTION_DETAIL</p></li>
<li><p>REPORT_UDIFF</p></li>
<li><p>REPORT_CDIFF</p></li>
<li><p>REPORT_NDIFF</p></li>
<li><p>REPORT_ONLY_FIRST_FAILURE</p></li>
</ul>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">raise_on_error</span></code> raises an exception on the
first unexpected exception or failure. This allows failures to be
post-mortem debugged.</p>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">parser</span></code> specifies a DocTestParser (or
subclass) that should be used to extract tests from the files.</p>
<p>Optional keyword arg <code class="docutils literal notranslate"><span class="pre">encoding</span></code> specifies an encoding that should
be used to convert the file to unicode.</p>
<p>Advanced tomfoolery:  testmod runs methods of a local instance of
class doctest.Tester, then merges the results into (or creates)
global Tester instance doctest.master.  Methods of doctest.master
can be called directly too, if you want to do something unusual.
Passing report=0 to testmod is especially useful then, to delay
displaying a summary.  Invoke doctest.master.summarize(verbose)
when you’re done fiddling.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.testing.runtests.test">
<span class="sig-prename descclassname"><span class="pre">sympy.testing.runtests.</span></span><span class="sig-name descname"><span class="pre">test</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">paths</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subprocess</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rerun</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/testing/runtests.py#L340-L504"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.testing.runtests.test" title="Permalink to this definition">¶</a></dt>
<dd><p>Run tests in the specified test_*.py files.</p>
<p>Tests in a particular test_*.py file are run if any of the given strings
in <code class="docutils literal notranslate"><span class="pre">paths</span></code> matches a part of the test file’s path. If <code class="docutils literal notranslate"><span class="pre">paths=[]</span></code>,
tests in all test_*.py files are run.</p>
<p>Notes:</p>
<ul class="simple">
<li><p>If sort=False, tests are run in random order (not default).</p></li>
<li><p>Paths can be entered in native system format or in unix,
forward-slash format.</p></li>
<li><p>Files that are on the blacklist can be tested by providing
their path; they are only excluded if no paths are given.</p></li>
</ul>
<p><strong>Explanation of test results</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 9%" />
<col style="width: 91%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Output</p></th>
<th class="head"><p>Meaning</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>.</p></td>
<td><p>passed</p></td>
</tr>
<tr class="row-odd"><td><p>F</p></td>
<td><p>failed</p></td>
</tr>
<tr class="row-even"><td><p>X</p></td>
<td><p>XPassed (expected to fail but passed)</p></td>
</tr>
<tr class="row-odd"><td><p>f</p></td>
<td><p>XFAILed (expected to fail and indeed failed)</p></td>
</tr>
<tr class="row-even"><td><p>s</p></td>
<td><p>skipped</p></td>
</tr>
<tr class="row-odd"><td><p>w</p></td>
<td><p>slow</p></td>
</tr>
<tr class="row-even"><td><p>T</p></td>
<td><p>timeout (e.g., when <code class="docutils literal notranslate"><span class="pre">--timeout</span></code> is used)</p></td>
</tr>
<tr class="row-odd"><td><p>K</p></td>
<td><p>KeyboardInterrupt (when running the slow tests with <code class="docutils literal notranslate"><span class="pre">--slow</span></code>,
you can interrupt one of them without killing the test runner)</p></td>
</tr>
</tbody>
</table>
<p>Colors have no additional meaning and are used just to facilitate
interpreting the output.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">sympy</span>
</pre></div>
</div>
<p>Run all tests:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>    
</pre></div>
</div>
<p>Run one file:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="s2">&quot;sympy/core/tests/test_basic.py&quot;</span><span class="p">)</span>    
<span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="s2">&quot;_basic&quot;</span><span class="p">)</span>    
</pre></div>
</div>
<p>Run all tests in sympy/functions/ and some particular file:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="s2">&quot;sympy/core/tests/test_basic.py&quot;</span><span class="p">,</span>
<span class="gp">... </span>       <span class="s2">&quot;sympy/functions&quot;</span><span class="p">)</span>    
</pre></div>
</div>
<p>Run all tests in sympy/core and sympy/utilities:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="s2">&quot;/core&quot;</span><span class="p">,</span> <span class="s2">&quot;/util&quot;</span><span class="p">)</span>    
</pre></div>
</div>
<p>Run specific test from a file:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="s2">&quot;sympy/core/tests/test_basic.py&quot;</span><span class="p">,</span>
<span class="gp">... </span>       <span class="n">kw</span><span class="o">=</span><span class="s2">&quot;test_equality&quot;</span><span class="p">)</span>    
</pre></div>
</div>
<p>Run specific test from any file:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">kw</span><span class="o">=</span><span class="s2">&quot;subs&quot;</span><span class="p">)</span>    
</pre></div>
</div>
<p>Run the tests with verbose mode on:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">verbose</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>    
</pre></div>
</div>
<p>Don’t sort the test output:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">sort</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>    
</pre></div>
</div>
<p>Turn on post-mortem pdb:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">pdb</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>    
</pre></div>
</div>
<p>Turn off colors:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">colors</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>    
</pre></div>
</div>
<p>Force colors, even when the output is not to a terminal (this is useful,
e.g., if you are piping to <code class="docutils literal notranslate"><span class="pre">less</span> <span class="pre">-r</span></code> and you still want colors)</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">force_colors</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>    
</pre></div>
</div>
<p>The traceback verboseness can be set to “short” or “no” (default is
“short”)</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">tb</span><span class="o">=</span><span class="s1">&#39;no&#39;</span><span class="p">)</span>    
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">split</span></code> option can be passed to split the test run into parts. The
split currently only splits the test files, though this may change in the
future. <code class="docutils literal notranslate"><span class="pre">split</span></code> should be a string of the form ‘a/b’, which will run
part <code class="docutils literal notranslate"><span class="pre">a</span></code> of <code class="docutils literal notranslate"><span class="pre">b</span></code>. For instance, to run the first half of the test suite:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">split</span><span class="o">=</span><span class="s1">&#39;1/2&#39;</span><span class="p">)</span>  
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">time_balance</span></code> option can be passed in conjunction with <code class="docutils literal notranslate"><span class="pre">split</span></code>.
If <code class="docutils literal notranslate"><span class="pre">time_balance=True</span></code> (the default for <code class="docutils literal notranslate"><span class="pre">sympy.test</span></code>), sympy will attempt
to split the tests such that each split takes equal time.  This heuristic
for balancing is based on pre-recorded test data.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">split</span><span class="o">=</span><span class="s1">&#39;1/2&#39;</span><span class="p">,</span> <span class="n">time_balance</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>  
</pre></div>
</div>
<p>You can disable running the tests in a separate subprocess using
<code class="docutils literal notranslate"><span class="pre">subprocess=False</span></code>.  This is done to support seeding hash randomization,
which is enabled by default in the Python versions where it is supported.
If subprocess=False, hash randomization is enabled/disabled according to
whether it has been enabled or not in the calling Python process.
However, even if it is enabled, the seed cannot be printed unless it is
called from a new Python process.</p>
<p>Hash randomization was added in the minor Python versions 2.6.8, 2.7.3,
3.1.5, and 3.2.3, and is enabled by default in all Python versions after
and including 3.3.0.</p>
<p>If hash randomization is not supported <code class="docutils literal notranslate"><span class="pre">subprocess=False</span></code> is used
automatically.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sympy</span><span class="o">.</span><span class="n">test</span><span class="p">(</span><span class="n">subprocess</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>     
</pre></div>
</div>
<p>To set the hash randomization seed, set the environment variable
<code class="docutils literal notranslate"><span class="pre">PYTHONHASHSEED</span></code> before running the tests.  This can be done from within
Python using</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">os</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">&#39;PYTHONHASHSEED&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;42&#39;</span> 
</pre></div>
</div>
<p>Or from the command line using</p>
<p>$ PYTHONHASHSEED=42 ./bin/test</p>
<p>If the seed is not set, a random seed will be chosen.</p>
<p>Note that to reproduce the same hash values, you must use both the same seed
as well as the same architecture (32-bit vs. 64-bit).</p>
</dd></dl>

</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h4>Previous topic</h4>
  <p class="topless"><a href="randtest.html"
                        title="previous chapter">Randomised Testing</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../utilities/index.html"
                        title="next chapter">Utilities</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/testing/runtests.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../utilities/index.html" title="Utilities"
             >next</a> |</li>
        <li class="right" >
          <a href="randtest.html" title="Randomised Testing"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >Testing</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Run Tests</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/testing/runtests.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:11 GMT -->
</html>